package com.zhuqiao.server1.intercept;

import com.zhuqiao.tm.transactional.MyTransactionManager;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class RequestInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        String groupId = request.getHeader("groupId");
        String transactionCount = request.getHeader("transactionCount");
        MyTransactionManager.setCurrentGroupId(groupId);
        MyTransactionManager.setTransactionCount(transactionCount);
        return true;
    }
}
